<?php 


class WeiboAuthServiceComponent extends CApplicationComponent {
 
	/**
	 * Bind Weibo 
	 * @param unknown_type $pid
	 * @param unknown_type $oauth_verifier
	 */
	public function bind($pid,$oauth_verifier){
		
	  $last_key = WeiboApiFactory::getAccessToken($pid, $oauth_verifier);
            //oauth_token    'oauth_token_secret' 
            
            if(isset($last_key['oauth_token'])){
              
                
                $pid = $_GET['pid'];
                
              
                $up = new UserProvidor;
                
                $up->pid = $pid;
                $up->uid = Yii::app()->user->uid ;
                $up->puid =$last_key['user_id'] ;
                $up->type = Providor::$AUTH_TYPE[$pid];
                $up->aKey = $last_key ['oauth_token'];
                $up->sKey = $last_key ['oauth_token_secret'];
                
                if($up->save()){
//                     Yii::app()->user->setFlash('Acount_Msg','Bind OK.'.var_export($last_key,true));
                     return $up;
                }
            }else{
            	return false;
            }
	}
}
 ?>
